Imports System.Data.OracleClient
Namespace persistent
    Public Class GhhDefination

        Public Shared Function AddGhhProduct(ByVal configId As Integer, ByRef resultMessage As String, ByVal user As String)

            resultMessage = String.Empty

            Dim resultMessParameter As OracleClient.OracleParameter

            Dim con As New OracleConnection(ConfigurationSettings.AppSettings("OraConnStr"))
            con.Open()
            Dim cmd As New OracleCommand
            cmd.Connection = con
            cmd.CommandText = "eu_bill.pkg_ghh_config.add_ghh_product"
            cmd.CommandType = CommandType.StoredProcedure

            cmd.Parameters.Add("p_config_id", OracleType.Int32).Value = configId
            cmd.Parameters.Add("p_user_id", OracleType.NVarChar).Value = user

            resultMessParameter = cmd.Parameters.Add(New OracleClient.OracleParameter("p_result_mes", OracleClient.OracleType.VarChar, 1000))
            resultMessParameter.Direction = ParameterDirection.Output

            cmd.ExecuteNonQuery()

            resultMessage = resultMessParameter.Value

            con.Close()
        End Function

        Public Shared Function GetNewXmlConfigID(ByRef configId As Integer, ByVal user As String, ByVal actionTypeId As Integer)


            Dim resultMessParameter As OracleClient.OracleParameter

            Dim con As New OracleConnection(ConfigurationSettings.AppSettings("OraConnStr"))
            con.Open()
            Dim cmd As New OracleCommand
            cmd.Connection = con
            cmd.CommandText = "eu_bill.pkg_ghh_config.get_new_xml_config_id"
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add("p_user_id", OracleType.VarChar).Value = user
            cmd.Parameters.Add("p_action_type_id", OracleType.Int32).Value = actionTypeId

            resultMessParameter = cmd.Parameters.Add(New OracleClient.OracleParameter("p_config_id", OracleClient.OracleType.Int32))
            resultMessParameter.Direction = ParameterDirection.Output

            cmd.ExecuteNonQuery()

            configId = Integer.Parse(resultMessParameter.Value())

            con.Close()
        End Function


        Public Shared Function AppendXmlString(ByVal configId As Integer, ByVal xmlString As String, ByVal status As String)

            Dim resultMessParameter As OracleClient.OracleParameter

            Dim con As New OracleConnection(ConfigurationSettings.AppSettings("OraConnStr"))
            con.Open()
            Dim cmd As New OracleCommand
            cmd.Connection = con
            cmd.CommandText = "eu_bill.pkg_ghh_config.append_xml_string"
            cmd.CommandType = CommandType.StoredProcedure

            cmd.Parameters.Add("p_config_id", OracleType.Int32).Value = configId
            cmd.Parameters.Add("p_xmlString", OracleType.NVarChar).Value = xmlString
            cmd.Parameters.Add("p_status", OracleType.NVarChar).Value = status

            cmd.ExecuteNonQuery()

            con.Close()
        End Function

    End Class
End Namespace
